package zxd.controller;

import org.springframework.web.bind.annotation.*;
import zxd.biz.UserBL;
import zxd.entity.UserPage;
import zxd.util.Data;
import zxd.util.Message;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 张旭东 on 2017/8/30.
 */
@RestController
public class TestController {


    @RequestMapping(value = "/test", method = RequestMethod.POST)
    @ResponseBody
    public Map test(@RequestBody UserPage userPage, HttpServletRequest request) {
        System.out.println("-------接收到前端请求-------" + userPage);
        Data dataMap = new Data();
        dataMap.put(userPage);
        UserBL userBL = new UserBL();
        userBL.deal("insert",dataMap);
        if(userBL.getResultFlag()){
            return Message.succMap(userBL.getResultList());
        }else{
            return Message.failMap(userBL.getErrorMSG());
        }

    }
    @RequestMapping(value = "/userQuery", method = RequestMethod.POST)
    @ResponseBody
    public Map userQuery(@RequestBody UserPage userPage, HttpServletRequest request) {
        System.out.println("-------接收到前端请求-------" + userPage);
        Data dataMap = new Data();
        dataMap.put(userPage);
        UserBL userBL = new UserBL();
        userBL.deal("query",dataMap);
        if(userBL.getResultFlag()){
            return Message.succMap(userBL.getResultList());
        }else{
            return Message.failMap(userBL.getErrorMSG());
        }

    }

}
